<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>角色修改</title>
    <meta name="description" content="这是一个角色管理页面">
    <meta name="keywords" content="角色管理">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="${contextPath}/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="${contextPath}/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="${contextPath}/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="${contextPath}/assets/css/amazeui.tree.min.css"/>
    <link rel="stylesheet" href="${contextPath}/assets/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href="${contextPath}/assets/css/app.css">
    <script src="${contextPath}/assets/js/jquery.min.js"></script>

</head>

<body data-type="widgets">
<script src="${contextPath}/assets/js/theme.js"></script>
<div class="am-g tpl-g">
    <!-- 头部 -->
    <#include "/pc/common/header.html">
        <!-- 侧边导航栏 -->
        <#include "/pc/common/left.html">
            <!-- 内容区域 -->
            <div class="tpl-content-wrapper">
                <div class="row-content am-cf">
                    <div class="row">
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                            <div class="widget am-cf">
                                <ol class="am-breadcrumb widget-head">
                                    <li><a href="${contextPath}/index.htm" class="am-icon-home">首页</a></li>
                                    <li>系统管理</li>
                                    <li><a href="${contextPath}/user/list.htm">用户信息</a></li>
                                    <li>角色修改</li>
                                </ol>
                                <div class="widget-body  am-fr">
                                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                        <div class="am-form-group">
                                            <div class="am-btn-toolbar">
                                                <div class="am-btn-group am-btn-group-xs">
                                                    <button type="button" onclick="plus_b()"
                                                            class="am-btn am-btn-default am-btn-success"><span
                                                            class="am-icon-plus"></span> 全部展开
                                                    </button>
                                                    <button type="button" onclick="minus_b()"
                                                            class="am-btn am-btn-default am-btn-danger"><span
                                                            class="am-icon-minus"></span> 全部关闭
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="am-u-sm-12">
                                        <div class="am-form-group">
                                            <ul class="am-tree" id="firstTree">
                                                <li class="am-tree-branch am-hide" data-template="treebranch">
                                                    <div class="am-tree-branch-header">
                                                        <button class="am-tree-branch-name">
                                                            <span class="am-tree-icon am-tree-icon-folder"></span>
                                                            <span class="am-tree-label"></span>
                                                        </button>
                                                    </div>
                                                    <ul class="am-tree-branch-children"></ul>
                                                    <div class="am-tree-loader"><span
                                                            class="am-icon-spin am-icon-spinner"></span></div>
                                                </li>
                                                <li class="am-tree-item am-hide" data-template="treeitem">
                                                    <button class="am-tree-item-name">
                                                        <span class="am-tree-icon am-tree-icon-item"></span>
                                                        <span class="am-tree-label"></span>
                                                    </button>
                                                </li>
                                            </ul>
                                        </div>

                                        <div class="am-form-group">
                                            <div class="am-u-sm-10 am-u-sm-offset-2">
                                                <button type="button" onclick="save_b()" class="am-btn am-btn-primary">
                                                    保存
                                                </button>
                                                <a href="javascript:history.back();"
                                                   class="am-btn am-btn-default">返回</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
</div>
</div>
<#include "/pc/common/alert.html">
<script src="${contextPath}/assets/js/amazeui.min.js"></script>
<script src="${contextPath}/assets/js/amazeui.tree.min.js"></script>
<script src="${contextPath}/assets/js/amazeui.datatables.min.js"></script>
<script src="${contextPath}/assets/js/dataTables.responsive.min.js"></script>
<script type="text/javascript" src="${contextPath}/assets/js/amazeui.page.js"></script>
<script src="${contextPath}/assets/js/app.js"></script>
<script>
    $(document).ready(function () {
        $('#firstTree').tree({
            dataSource: function (options, callback) {
                callback({data: options.children || ${tree!''}});
            },
            multiSelect: true,
            cacheItems: true,
            folderSelect: false
        });
        selected();
    });
    function selected(){
        $('#firstTree').tree('discloseAll');
        <#list ids as id>
        $('#firstTree').tree('selectItem', $('#${id}'));
        </#list>
    }
    function plus_b() {
        $('#firstTree').tree('discloseAll');
    }

    function minus_b() {
        $('#firstTree').tree('closeAll');
    }

    function save_b() {
        var items = $('#firstTree').tree('selectedItems');
        var ids = "";
        for(var i=0;i<items.length;i++){
            ids+=items[i].attr.id+",";
        }
        $.ajax({
            url:"${contextPath}/role/jstreesave.htm",
            data:{id:${yhid},ids:ids},
            dataType:"json",
            type:"POST",
            success:function(data){
                var json = $.parseJSON(data);
                Malert(json.errMessage);
            }
        });
    }
</script>
</body>

</html>